/** @odoo-module **/
class GroupRowInnerRenderer {
    // 初始化
    init(params){
        // console.log(params.value);
        // 同一餐大荤1 素菜3 小荤2 全部是辣的
        // let dinner_type_arr =  [
        //     {name: '午餐', id: 'dn2'},
        //     {name: '晚餐', id: 'dn3'},
        //     {name: '夜餐', id: 'dn5'},
        //     {name: '早餐', id: 'dn1'},
        // ];
        let weekStr = '一二三四五六日';
        let dinner_type_category = params.context.owl_widget.index.dinner_type_category||[]
        let dish_top_categorys = params.context.owl_widget.index.dish_top_category||[];
        let dinner_type_id = dinner_type_category.find(v=>v.name == params.value).id;

        let Count = params.context.owl_widget.countRowData;
        //绿色菜只考虑快餐  炸数量看全部菜品
        let tips = {
            spicy:[],
            fried:[],
            green:[]
        };
        for(let i = 1; i　< 8; i++) {
            Count['day'+i] && Count['day'+i][dinner_type_id] && Count['day'+i][dinner_type_id].fried > 1 && (tips.fried.push(`周${weekStr[i-1]}`));
            Count['day'+i] && Count['day'+i][dinner_type_id] && Count['day'+i][dinner_type_id].kuai && Count['day'+i][dinner_type_id].kuai.green == 0 && (tips.green.push(`周${weekStr[i-1]}`));
            Count['day'+i] && Count['day'+i][dinner_type_id] && Count['day'+i][dinner_type_id].kuai && Count['day'+i][dinner_type_id].kuai.spicy > 1 && (tips.spicy.push(`周${weekStr[i-1]}`));
        }

        let text = [];
        tips.spicy.length>0 && (text.push('有两个及以上的菜是辣的：'+tips.spicy.join('、')));
        tips.fried.length>0 && (text.push('有两个及以上的菜是油炸品：'+tips.fried.join('、')));
        tips.green.length>0 && (text.push('没有绿色菜：'+tips.green.join('、')));

        const eGui = document.createElement('div');
        let _html = '';
        _html += `<span class="" style="font-family:'黑体'">${params.value}</span>`;
        _html += `<span class="text-danger" style="margin-left: 5px;">${text.join('；')}</span>`;

        eGui.innerHTML = _html;
        this.eGui = eGui
    }
    // 插入页面
    getGui() {
        // console.log('GroupRowInnerRenderer');
        return this.eGui;
    }
    // 刷新
    refresh(params) {
        console.log('refresh');
        return false;
    }
}

export default GroupRowInnerRenderer
